package com.winz.cultureapp.activity;

import android.content.Intent;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;
import com.winz.cultureapp.R;
import com.winz.cultureapp.adapter.vp.NewsVpAdapter;
import com.winz.cultureapp.base.BaseAppCompatActivity;
import com.winz.cultureapp.fragment.PersonalItem1Fragment;
import com.winz.cultureapp.fragment.PersonalItem2Fragment;
import com.winz.cultureapp.fragment.PersonalItem4Fragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 个人记录
 */
public class PersonalRecordActivity extends BaseAppCompatActivity {
    @BindView(R.id.tv_top_title)
    TextView mTv_top_title;
    @BindView(R.id.stb_nav)
    SlidingTabLayout mStb_nav;
    @BindView(R.id.vp_list)
    ViewPager mVp_list;
    
    private String[] titles = {"场馆预定","活动预定"/*,"志愿服务"*/,"讲解预约"};
    private List<Fragment> fragments = new ArrayList<>();
    
    @Override
    protected int contentView() {
        return R.layout.activity_personal_record;
    }

    @Override
    protected void initViews() {
        mTv_top_title.setText(R.string.mine_title2);
        fragments.add(PersonalItem1Fragment.getInstance(titles[0]));
        fragments.add(PersonalItem2Fragment.getInstance(titles[1]));
//        fragments.add(PersonalItem3Fragment.getInstance(titles[2]));
        fragments.add(PersonalItem4Fragment.getInstance(titles[2]));
        NewsVpAdapter mAdapter = new NewsVpAdapter(getSupportFragmentManager(),fragments, titles);
        mVp_list.setAdapter(mAdapter);

        mStb_nav.setViewPager(mVp_list,titles);
    }

    @Override
    protected void loadDatas(Intent intent) {
        if (intent != null){
            if (intent.getExtras() != null){
                int index = intent.getExtras().getInt("index", -1);
                if (index != -1){
                    mVp_list.setCurrentItem(index);
                }
            }
        }
    }

    @OnClick(R.id.fl_back)
    public void onClick() {
        finish();
    }
}
